package com.jy.wms.web;

import com.jy.wms.service.SysMenuService;
import net.sf.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
import java.util.Random;

/*
* 预期到货通知单
* 路由页面
* */
@Controller
@RequestMapping("/yqdh")
public class YqdhRouter {
    @Autowired
    SysMenuService menuService;
    //主页面
    @RequestMapping(value = "/toYqdh/{menu}")
    public String toKczy(@PathVariable String menu, Model model) {
        model.addAttribute("functions",menuService.getFunctions(menu));
        return "inOperation/yqdh/yqdh";
    }
    //增加页面
    @RequestMapping(value = "/addYqdh")
    public String addYqdh(Model model) {
        SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");//设置日期格式
        //ASN编号默认赋值
        String num = "";
        Random random = new Random();
        for (int i=0;i<6;i++) {
            num += random.nextInt(10);
        }
        String sj=df.format(new Date())+num;
        model.addAttribute("sj",sj);

        return "inOperation/yqdh/addYqdh";
    }
    //PO提取
    @RequestMapping(value = "/addPO")
    public String addPO() {

        return "inOperation/yqdh/savePO";
    }
    //查看po明细（选择提取条数）
    @RequestMapping(value = "/getOnePO")
    public String getOnePO(String id, Model model) {
        model.addAttribute("id",id);
        return "inOperation/yqdh/potqMx";
    }
    //查看预期到货明细
    @RequestMapping(value = "/getMingXiInfo")
    public String getMingXiInfo(String id,String shzt,String gysid, Model model) {
        model.addAttribute("id",id);
        model.addAttribute("shzt",shzt);
        model.addAttribute("gysid",gysid);
        return "inOperation/yqdh/addPotq";
    }
    //查看ASN收货
    @RequestMapping(value = "/getAsnMx")
    public String getAsnMx(String id, Model model) {
        model.addAttribute("id",id);
        return "inOperation/yqdh/asnShMx";
    }
    //附件管理
    @RequestMapping(value = "/getEnclosure")
    public String getEnclosure(String id, Model model) {
        model.addAttribute("id",id);
        return "inOperation/yqdh/upload";
    }
    //修改明细
    @RequestMapping(value = "/updateMx")
    public String updateMx(String id,String gysid, Model model) {
        model.addAttribute("id",id);
        model.addAttribute("gysid",gysid);
        return "inOperation/yqdh/updateMx";
    }
}
